package org.zn.note.common.util;

import java.io.Closeable;
import java.io.IOException;
import java.util.List;

/**
 * @ClassName NetUtil
 * @Author zn
 * @Date 2019/4/4 15:34
 **/
public class IOUtil {

    public static void close(Closeable closeable) {
        if(null != closeable) {
            try {
                closeable.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    public static void close(AutoCloseable closeable) {
        if(null != closeable) {
            try {
                closeable.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    public static void close(AutoCloseable... closeableList) {
        for(AutoCloseable closeable : closeableList) {
            close(closeable);
        }
    }

    public static void close(List<Closeable> closeableList) {
        for(Closeable closeable : closeableList) {
            close(closeable);
        }
    }
}
